local hx__laidadcw = fk.CreateSkill {
  name = "hx__laidadcw",
}

hx__laidadcw:addEffect("viewas", {
  pattern = "slash,jink",
  interaction = function(self, player)
    local all_names = { "slash", "jink" }
    local names = player:getViewAsCardNames( hx__laidadcw.name, all_names)
    return UI.CardNameBox { choices = names, all_choices = all_names }
  end,
  card_filter = function(self, player, to_select, selected)
    return false
  end,
  view_as = function(self, player,cards)
    if not self.interaction.data then return end
    local c = Fk:cloneCard(self.interaction.data)
    c.skillName = hx__laidadcw.name
    return c
  end,
  before_use = function(self, player, use)
    local room = player.room
    room:removePlayerMark(player,"@hx__laidaczkr_chengzi", 1)
  end,
  enabled_at_play = function(self, player)
    return player:getMark("@hx__laidaczkr_chengzi") > 0
  end,
  enabled_at_response = function(self, player)
    return player:getMark("@hx__laidaczkr_chengzi") > 0
  end,
})

hx__laidadcw:addEffect(fk.TurnEnd, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    local tos = {}
    player.room.logic:getEventsOfScope(GameEvent.Recover, 999, function (e)
      if e.data.who ~= nil then
        table.insert(tos, e.data.who)
      end
    end, Player.HistoryTurn)
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return player:hasSkill(hx__laidadcw.name)
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local tos = event:getCostData(self).tos
    local to = room:askToChoosePlayers(player, {
      prompt = "请选择一名本回合回复过体力的角色，视为你对其使用一张【杀】",
      targets = tos,
      min_num = 1,
      max_num = 1,
      cancelable = true,
      skill_name = hx__laidadcw.name,
    })
    if to then
      event:setCostData(self, {extra_data = to[1]})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local to = event:getCostData(self).extra_data
    local card = Fk:cloneCard("slash")
    card.skillName = hx__laidadcw.name
    local use = {card = card, from = player, tos = {to}, extraUse = true }
    player.room:useCard(use)
  end,
})


return hx__laidadcw